#include <stack>
#include <iostream>

using namespace std;

class minStack
{
private:
	stack<int> mainS;
	stack<int> minS;
public:
	void pop();
	void push(const int& x);
	int min();
};

void minStack::pop()
{
	minS.pop();
	mainS.pop();
	cout<<"min:"<<min()<<endl;
}

void minStack::push(const int& x)
{
	if(mainS.empty())
	{
		minS.push(x);
		//cout<<"1"<<endl;
	}
	else 
	{
		int min = minS.top();
		if(min > x)
			minS.push(x);
		else
			minS.push(min);
	}
	mainS.push(x);
	cout<<"min:"<<min()<<endl;
}

int minStack::min()
{
	return minS.top();
}

int main()
{
	minStack s;
	s.push(3);
	s.push(4);
	s.push(2);
	s.push(1);
	s.pop();
	s.pop();
	s.push(0);
}

